﻿using System;

namespace 结构体加深
{
    public struct Books
    {
        // 字段
        private int Book_Id;
        private string Book_Title;
        private string Book_Author;
        private string Book_Type;

        // 委托
        public delegate void Callback(string mess);

        // 事件
        public event Callback BookCallbock;

        // 属性
        public int Id { get; set; }
        public string Name { get; set; }

        // 方法

        public string GetName()
        {
            BookCallbock?.Invoke(Name);
            return Name;
        }

    }

    public struct ReturnData
    {
        public int Id;
        public string Name;

        // 结构体构造
        public ReturnData(int id, string name)
        {
            Id = id;
            Name = name;
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            // MainWriteln();

            ReturnData GD = GetData();
        }

        // 返回结构体数据
        private static ReturnData GetData()
        {
            return new ReturnData(1, "于晟");
        }

        private static void MainWriteln()
        {
            Books books1 = new Books();
            Books books2 = new Books();
            books1.Id = 1;
            books1.Name = "大话数据结构";

            books2.Id = 2;
            books2.Name = "大话设计模式";

            Console.WriteLine("Book 1 id : {0}", books1.Id);
            Console.WriteLine("Book 1 title : {0}", books1.GetName());

            Console.WriteLine("Book 2 id : {0}", books2.Id);
            Console.WriteLine("Book 2 title : {0}", books2.Name);

        }

    }
}
